/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.geftu.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.validator.constraints.NotEmpty;

/**
 *
 * @author jorgenei
 */
@Entity
@Table(name = "tb_desenvolvedor", catalog = "bddefeitos", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Desenvolvedor.findAll", query = "SELECT t FROM Desenvolvedor t"),
    @NamedQuery(name = "Desenvolvedor.findByIddes", query = "SELECT t FROM Desenvolvedor t WHERE t.iddes = :iddes"),
    @NamedQuery(name = "Desenvolvedor.findByNome", query = "SELECT t FROM Desenvolvedor t WHERE t.nome = :nome"),
    @NamedQuery(name = "Desenvolvedor.findByCpf", query = "SELECT t FROM Desenvolvedor t WHERE t.cpf = :cpf"),
    @NamedQuery(name = "Desenvolvedor.findByLogin", query = "SELECT t FROM Desenvolvedor t WHERE t.login = :login"),
    @NamedQuery(name = "Desenvolvedor.findBySenha", query = "SELECT t FROM Desenvolvedor t WHERE t.senha = :senha")})
public class Desenvolvedor implements Serializable {

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "desenvolvedor")
    private Collection<Participa> ParticipaCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "iddes", sequenceName = "desenvolvedor_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "iddes")
    @Basic(optional = false)
    //@Column(name = "iddes", nullable = false)
    private Integer iddes;
    @NotNull(message = "O campo não pode ser nulo")
    @NotEmpty(message = "O campo não pode estar em branco")
    @Size(min = 4, max = 20, message = "O campo dever possuir entre 4 e 20 caracteres")
    @Column(name = "nome", length = 255)
    private String nome;
        @NotNull(message = "O campo não pode ser nulo")
    @NotEmpty(message = "O campo não pode estar em branco")
    @Size(min = 4, max = 20, message = "O campo dever possuir entre 11 caracteres")
    @Column(name = "cpf", length = 255)
    private String cpf;
    @Column(name = "Celular", length = 20)
    private String celular;
    @Column(name = "login", length = 20)
    private String login;
    @Column(name = "senha", length = 30)
    private String senha;

    public Desenvolvedor() {
    }

    public Desenvolvedor(Integer iddes) {
        this.iddes = iddes;
    }

    public Integer getIddes() {
        return iddes;
    }

    public void setIddes(Integer iddes) {
        this.iddes = iddes;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getCpf() {
        return cpf;
    }

    public void setCpf(String cpf) {
        this.cpf = cpf;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddes != null ? iddes.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Desenvolvedor)) {
            return false;
        }
        Desenvolvedor other = (Desenvolvedor) object;
        if ((this.iddes == null && other.iddes != null) || (this.iddes != null && !this.iddes.equals(other.iddes))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + iddes;
    }

    @XmlTransient
    public Collection<Participa> getParticipaCollection() {
        return ParticipaCollection;
    }

    public void setParticipaCollection(Collection<Participa> ParticipaCollection) {
        this.ParticipaCollection = ParticipaCollection;
    }

}
